package net.kleinhenz.questor.game;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Random;

/**
 * Dice simulator. Implements random dice rolls.
 * 
 * @author Michael Kleinhenz, m.kleinhenz@tarent.de
 */
public class Dice
{
	private static Random rnd = new Random(new Date().getTime());

	/**
	 * Rolls a W6, returns the result.
	 * 
	 * @return dice result.
	 */
	public static int roll()
	{
		return roll(6);
	}

	/**
	 * Rolls a Wx, returns the result.
	 * 
	 * @param w type of dice, count of sides.
	 * @return dice result. 
	 */
	public static int roll(int w)
	{
		return rnd.nextInt(w)+1;
	}

	/**
	 * Rolls multiple W6, returns list of results.
	 * 
	 * @param d count of W6 to roll.
	 * @return List of dice results.
	 */
	public static List<Integer> multiRoll(int d)
	{
		return roll(d, 6);
	}

	/**
	 * Rolls multiple Wx, returns list of results.
	 * 
	 * @param d count of W6 to roll.
	 * @param w type of dice, count of sides.
	 * @return List of dice results.
	 */
	public static List<Integer> roll(int d, int w)
	{
		List<Integer> result = new ArrayList<Integer>();
		for (int i=0; i<d; i++)
			result.add(roll(w));		
		return result;
	}
}
